﻿Public Class Drelacion

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String) As List(Of Erelacion)
        Dim relacions As List(Of Erelacion) = Nothing 'Es una coleccion de lista tipado (vendedor)

        Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings(descEmpresa).ConnectionString)
            Using cmd As New SqlCommand("usp_relacion_sel", cn)
                cmd.CommandType = CommandType.StoredProcedure
                Try
                    cn.Open()
                    Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.CloseConnection)
                        If dr.HasRows Then
                            relacions = New List(Of Erelacion)
                            Dim relacion As Erelacion = Nothing 'tipo 
                            Do While dr.Read
                                relacion = New Erelacion( _
                                    dr.GetInt32(dr.GetOrdinal("idRelacion")), _
                                    dr.GetString(dr.GetOrdinal("descRelacion")))
                                relacions.Add(relacion)
                            Loop
                            dr.Close()
                        End If
                    End Using
                Catch ex As Exception
                    Throw
                End Try
            End Using
        End Using

        Return relacions
    End Function

End Class
